<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    const nums1 = [4,9,5]
    const nums2 = [9,4,9,8,4]
    function intersection (nums1, nums2) {
      const arr = []
      for(let i = 0; i < nums1.length; i++) {
        for(let j = 0; j < nums2.length; j++){
          if(nums1[i] === nums2[j]){
            arr.push(nums1[i])
          }
        }
      }
      return [...new Set(arr)]
      
    };
    console.log(intersection (nums1, nums2));

  </script>
</body>
</html>